/*-+-*****************************************************************************
 Copyright (C) 2009-2012 Oceanside Software Corporation (R)
 Dallas, Texas

 Author       : Jason T. Brower
 Purpose      : This file is part of a point-of-sale software package
                originally written for Table-Service Restaurants.
              
 Date         : July 8th of 2012
              
 History      : The application that this software file belongs to was 
                written over a 3-Year period.  The first version was written
                in C# .Net 3.5 using Windows Forms.  Being new to .Net at
                the time, I soon learned of Windows Presentation Foundation,
                liked the graphics capabilities and databinding so I
                migrated to WPF.  When the .Net 4.0 framework was released
                the application was migrated from 3.5 to 4.0. Now today,
                .Net 4.5 RC is out and I was already in process of migrating
                before I made this public.
                
Excuse Me     : Please excuse the coding style, it is not representative of
                my typical work.  During the three years I was under a very
                tight budget, constantly running out of funding and was 
                working 18 hour days hyped up on 5-Hour Energy.  The 
                design is not textbook.  It is monolythic because of
                previous issues I will not get into.  There are few comments
                in the code and the ones that are there may be incorrect.
                
What it is not: This is not the exact version that I took through PA-DSS 2.0
                nor is it the exact version running at my customer sites.
                I removed some details for security purposes including some
                encryption algorithms.  The reporting was removed because
                I was including a third party library that cannot be 
                published with this Open Source.
                
What it is    : This application has been running at high volume restaraunts
                for over a year.  It never freezes, crashes or does anything
                unexpected.  So long as it is built, installed and configured
                correctly, it is a strong system that we can all enhance.

Contact       : Please note that I can no longer work for free.  However, you
                can reach me at information@oceansidesw.com.                                                      

*********************************************************************************/
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace Oceanside
{
    /// <summary>
    /// Interaction logic for ShineButton_124_124.xaml
    /// </summary>
    public partial class ShineButton_124_124 : UserControl
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public ShineButton_124_124()
        {
            this.InitializeComponent();

            ///Register for the mouse events so we can behave like a real button.
            this.MouseDown += new MouseButtonEventHandler(ShineButton_124_124_MouseDown_NOTHROW);
            this.MouseUp += new MouseButtonEventHandler(ShineButton_124_124_MouseUp_NOTHROW);
            this.MouseLeave += new MouseEventHandler(ShineButton_124_124_MouseLeave_NOTHROW);
        }

        /// <summary>
        /// Static constructor that will register for DP props.
        /// </summary>
        static ShineButton_124_124()
        {
            FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonBgChanged));
            ButtonBackgroundProperty = DependencyProperty.Register(
                "ButtonBackground",
                typeof(Brush),
                typeof(ShineButton_124_124),
                metadata
            );

            ButtonBackgroundMouseDownProperty = DependencyProperty.Register(
                "ButtonBackgroundMouseDown",
                typeof(Brush),
                typeof(ShineButton_124_124) ///Note the lack of metadata thats not needed for this one
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonButtonBBChanged));
            ButtonBorderBrushProperty = DependencyProperty.Register(
                "ButtonBorderBrush",
                typeof(Brush),
                typeof(ShineButton_124_124),
                metadata
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonGlareChanged));
            ButtonGlareProperty = DependencyProperty.Register(
                "ButtonGlare",
                typeof(Brush),
                typeof(ShineButton_124_124),
                metadata
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonButtonTextColorChanged));
            ButtonTextColorProperty = DependencyProperty.Register(
                "ButtonTextColor",
                typeof(Brush),
                typeof(ShineButton_124_124),
                metadata
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonTextChanged));
            ButtonLabelTextProperty = DependencyProperty.Register(
                "ButtonLabelText",
                typeof(String),
                typeof(ShineButton_124_124),
                metadata
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonTextFontSizeSizeChanged));
            ButtonTextFontSizeProperty = DependencyProperty.Register(
                "ButtonTextFontSize",
                typeof(Double),
                typeof(ShineButton_124_124),
                metadata
            );

            metadata = new FrameworkPropertyMetadata(new PropertyChangedCallback(OnButtonTextFontFamilyChanged));
            ButtonTextFontFamilyProperty = DependencyProperty.Register(
                "ButtonTextFontFamily",
                typeof(FontFamily),
                typeof(ShineButton_124_124),
                metadata
            );
        }



        /// <summary>
        /// DP Property Callbacks
        /// </summary>
        public static void OnButtonBgChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonGradientButtonBase.Fill = (Brush)args.NewValue;
        }
        public static void OnButtonButtonBBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonBorder.BorderBrush = (Brush)args.NewValue;
        }
        public static void OnButtonGlareChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonTopWhiteGlare.OpacityMask = (Brush)args.NewValue;
        }
        public static void OnButtonButtonTextColorChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonLabel.Foreground = (Brush)args.NewValue;
        }
        public static void OnButtonTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonLabel.Text = (String)args.NewValue;
        }
        public static void OnButtonTextFontSizeSizeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonLabel.FontSize = (Double)args.NewValue;
        }

        public static void OnButtonTextFontFamilyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            ShineButton_124_124 sb = sender as ShineButton_124_124;
            sb.buttonLabel.FontFamily = (FontFamily)args.NewValue;
        }

        /// <summary>
        /// DP Properties
        /// </summary>
        public static readonly DependencyProperty ButtonBackgroundProperty;
        public Brush ButtonBackground
        {
            get { return (Brush)GetValue(ButtonBackgroundProperty); }
            set { SetValue(ButtonBackgroundProperty, value); }
        }

        public static readonly DependencyProperty ButtonBackgroundMouseDownProperty;
        public Brush ButtonBackgroundMouseDown
        {
            get { return (Brush)GetValue(ButtonBackgroundMouseDownProperty); }
            set { SetValue(ButtonBackgroundMouseDownProperty, value); }
        }

        public static readonly DependencyProperty ButtonBorderBrushProperty;
        public Brush ButtonBorderBrush
        {
            get { return (Brush)GetValue(ButtonBorderBrushProperty); }
            set { SetValue(ButtonBorderBrushProperty, value); }
        }

        public static readonly DependencyProperty ButtonGlareProperty;
        public Brush ButtonGlare
        {
            get { return (Brush)GetValue(ButtonGlareProperty); }
            set { SetValue(ButtonGlareProperty, value); }
        }

        public static readonly DependencyProperty ButtonTextColorProperty;
        public Brush ButtonTextColor
        {
            get { return (Brush)GetValue(ButtonTextColorProperty); }
            set { SetValue(ButtonTextColorProperty, value); }
        }

        public static readonly DependencyProperty ButtonLabelTextProperty;
        public String ButtonLabelText
        {
            get { return (String)GetValue(ButtonLabelTextProperty); }
            set { SetValue(ButtonLabelTextProperty, value); }
        }

        public static readonly DependencyProperty ButtonTextFontSizeProperty;
        public Double ButtonTextFontSize
        {
            get { return (Double)GetValue(ButtonTextFontSizeProperty); }
            set { SetValue(ButtonTextFontSizeProperty, value); }
        }

        public static readonly DependencyProperty ButtonTextFontFamilyProperty;
        public FontFamily ButtonTextFontFamily
        {
            get { return (FontFamily)GetValue(ButtonTextFontFamilyProperty); }
            set { SetValue(ButtonTextFontFamilyProperty, value); }
        }

#if _TESTMODE
        public void Down()
        {
            MouseButtonEventArgs mea = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left);
            mea.RoutedEvent = Mouse.MouseDownEvent;
            this.RaiseEvent(mea);
        }
        public void Up()
        {
            MouseButtonEventArgs mea = new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left);
            mea.RoutedEvent = Mouse.MouseUpEvent;
            this.RaiseEvent(mea);
        }
#endif
        /// <summary>
        ///  Mouse click events
        /// </summary>
        public void ShineButton_124_124_MouseUp_NOTHROW(object sender, MouseButtonEventArgs e)
        {
            try
            {

#if !_TESTMODE
                e.Handled = true;
#endif
                buttonGradientButtonBase.Fill = ButtonBackground;
            }
            catch (System.Exception exc)
            {
                Constants.ErrorDispatcher.Notify(Error.EType.E_BUTTON_124_124_UP, exc);
            }
        }

        public void ShineButton_124_124_MouseDown_NOTHROW(object sender, MouseButtonEventArgs e)
        {
            try
            {
                buttonGradientButtonBase.Fill = ButtonBackgroundMouseDown;
            }
            catch (System.Exception exc)
            {
                Constants.ErrorDispatcher.Notify(Error.EType.E_BUTTON_124_124_DWN, exc);
            }
        }

        void ShineButton_124_124_MouseLeave_NOTHROW(object sender, MouseEventArgs e)
        {
            try
            {
                e.Handled = true;
                buttonGradientButtonBase.Fill = ButtonBackground;
            }
            catch (System.Exception exc)
            {
                Constants.ErrorDispatcher.Notify(Error.EType.E_BUTTON_124_124_LEAVE, exc);
            }
        }
    }
}
